package com.example.opensdkdemo.ssapi;

import static com.example.opensdkdemo.MainActivity.APPKEY;
import static cn.com.cetccst.sdk.modelbase.ConstantsAPI.COMMAND_RECEIVE_PAYLOAD_MESSAGE;

import android.os.Bundle;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.opensdkdemo.R;

import java.util.Date;

import cn.com.cetccst.sdk.modelbase.BaseReq;
import cn.com.cetccst.sdk.modelbase.BaseResp;
import cn.com.cetccst.sdk.modelbiz.ReceivePayloadMessage;
import cn.com.cetccst.sdk.openapi.SSAPIFactory;
import cn.com.cetccst.sdk.openapi.SSBaseEntryActivity;

public class EntryActivity extends SSBaseEntryActivity {

    @Override
    protected void createCXApi() {
        api = SSAPIFactory.getInstance(this, APPKEY);
        if(api == null){
            Toast.makeText(this, "SS OpenSdk 初始化失败", Toast.LENGTH_SHORT).show();
        }
    }
    @Override
    public void onReq(BaseReq req) {
        switch (req.getType()) {
            case COMMAND_RECEIVE_PAYLOAD_MESSAGE: {
                //透传消息指令
                ReceivePayloadMessage.Req sendCloudMessageReq = (ReceivePayloadMessage.Req) req;
                //可选 返回response
                ReceivePayloadMessage.Resp resp = new ReceivePayloadMessage.Resp();
                resp.transaction = req.transaction;
                resp.errorCode = BaseResp.ErrCode.ERR_OK;
                api.sendResp(resp);
                //TODO 可以处理一些其它的，获取弹出页面
            }
            break;
        }

    }
}